from django.db import models
from apps.common.base.models import BaseModel
from apps.merchant.trade.models import Trade
from apps.system.user.models import User
from apps.system.admin.models import Admin
from apps.system.lessee.models import Lessee

class Shop(BaseModel):

    checkStatus = (
        ("PASS", "通过"),
        ("REFUSE", "拒绝"),
        ("CHECKING", "审核中"),
    )
    types = (
        ("0", "自营店"),
        ("1", "加盟店"),
        ("2", "直营店"),
        ("3", "供应商"),
    )
    lessee = models.ForeignKey(Lessee, related_name="lessee_shop", verbose_name='租户', on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False)
    trade = models.ForeignKey(Trade, related_name="trade_shop", verbose_name='行业', on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False)
    user=models.ForeignKey(User, related_name='user_shop', verbose_name='所属用户', on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False)
    admin=models.ForeignKey(Admin, related_name='admin_shop', verbose_name='管理员', on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False)
    name = models.CharField("名称", max_length=200, blank=True, null=True, default='')
    addr = models.CharField("地址", max_length=200, blank=True, null=True, default='')
    contacts = models.CharField("联系人", max_length=200, blank=True, default='')
    phone = models.CharField("电话", max_length=200, blank=True, default='')
    intro = models.CharField("介绍", max_length=200, blank=True, default='')
    coverUrl = models.CharField("门头照片", max_length=500, blank=True, null=True, default='')
    photoUrls = models.CharField("店内展示", max_length=2000, blank=True, null=True, default='')
    creditedName = models.CharField("账户名称", max_length=200, blank=True, null=True, default='')
    creditedBank = models.CharField("收款银行名称", max_length=200, blank=True, null=True, default='')
    creditedAccount = models.CharField("收款账户", max_length=500, blank=True, null=True, default='')
    bankCode=models.CharField("银行编号", max_length=200, blank=True)
    hots = models.IntegerField("人气", default=0)
    isRobot = models.BooleanField('是否是机器人', default=0)
    status = models.BooleanField("状态", default=0)
    checkStatus = models.CharField("审核状态", max_length=100, choices=checkStatus, blank=True, default='CHECKING')
    types = models.CharField("商户类型", max_length=100, choices=types, blank=True, default='1')

    latitude = models.DecimalField("纬度", max_digits=22, decimal_places=10, blank=True, null=True, default=0)
    longitude = models.DecimalField("经度", max_digits=22, decimal_places=10, blank=True, null=True, default=0)
    locationRange = models.DecimalField("搜索范围", max_digits=22, decimal_places=10, blank=True, null=True, default=0)

    serviceChargeRate = models.DecimalField("提现手续费率", max_digits=10, decimal_places=4, default=0)
    serviceCharge_min = models.DecimalField("最小提现金额", max_digits=10, decimal_places=2, default=10)
    serviceCharge_max = models.DecimalField("最大提现金额", max_digits=10, decimal_places=2, default=10000)
    serviceChargeNum = models.IntegerField("每日提现次数", default=1)
    discountsRate = models.DecimalField("让利比例", max_digits=10, decimal_places=2, default=0)

    class Meta:
        verbose_name = 'Shop'
        verbose_name_plural = verbose_name
